package com.cysd.ewmxns.ui.activity

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.cszy.ewmxns.base.BaseVMActivity
import com.cszy.ewmxns.ext.launch

import com.cysd.ewmxns.adapter.indexGridAdapter

import com.cysd.ewmxns.viewmodel.IndexViewModel
import com.cysd.ewmxns.viewmodel.MainViewModel
import com.hlyj.http.ad.NewGroMoreFeedAdManager
import com.hnyyac.ad.mds.IAdView
import com.hnyyac.ad.mds.IAdViewListener
import com.hnyyac.ad.mds.manager.AdManager
import com.hnyyac.ad.mds.manager.AdManager.AdLoadListener
import com.hnyyac.ad.mds.utils.BaseAdConstants
import qrrspeeelild.rqrc0ode.andro0ild.databinding.ActivitySelectChangjingBinding


class SelectChangjingActivity : BaseVMActivity<IndexViewModel, ActivitySelectChangjingBinding>(),IAdViewListener {
    private var adapter: indexGridAdapter? = null
    private var newGromoreFeedAd : NewGroMoreFeedAdManager? =null
    override fun initView(savedInstanceState: Bundle?) {
        mBinding.headTitle.headCenterTitle.setText("选择场景")
    }


    override fun initData() {
        //获取首页grid数据
        adapter = indexGridAdapter()
        mBinding.recyChangjing.layoutManager= GridLayoutManager(this,2)
        mBinding.recyChangjing.adapter=adapter
        adapter?.submitList(mViewModel.getIndexGrid())
        AdManager.loadChapin(
            this,
            21,
            this,
            object : AdLoadListener {
                override fun onAdLoadFailed(ad: IAdView?) {
                    newGromoreFeedAd = NewGroMoreFeedAdManager(this@SelectChangjingActivity, BaseAdConstants.FEEDAD_Id, mBinding?.fragmentContainer,62)
                    newGromoreFeedAd?.loadAd()
                }
            })

    }

    override fun initListener() {
       //返回
        mBinding.headTitle.headBack.setOnClickListener { v -> finish() }

        //非黑扫二维码
        mBinding.rvShibie.setOnClickListener {
            var bundle=Bundle()
            bundle.putString("type","general")
            launch(bundle,QrcodeActivity::class.java)
        }
        //非黑生成二维码
        mBinding.rvSc.setOnClickListener {
            launch(CreatQrCodeActivity::class.java)
        }
        //非黑扫码支付
        mBinding.rvPay.setOnClickListener {
            var bundle=Bundle()
            bundle.putString("type","general")
            launch(bundle,QrcodeActivity::class.java)
        }
        adapter?.setOnItemClickListener{adapter, view, position ->
            var bundle=Bundle()
            bundle.putString("type","general")
            launch(bundle,QrcodeActivity::class.java)
        }
    }

    override fun onTrigger(adView: IAdView) {

    }

    override fun onAdShow(adView: IAdView) {

    }

    override fun onAdClick(adView: IAdView) {

    }

    override fun onAdClose(adView: IAdView) {
        newGromoreFeedAd = NewGroMoreFeedAdManager(this@SelectChangjingActivity, BaseAdConstants.FEEDAD_Id, mBinding?.fragmentContainer,62)
        newGromoreFeedAd?.loadAd()
    }

    override fun onError(msg: String) {

    }

    override fun onLoadError(adView: IAdView) {

    }

    override fun onSuccess(adView: IAdView) {

    }

    override fun onLoad(adView: IAdView) {

    }

    override fun onSkipped() {

    }

    override fun onNoAd() {

    }

    override fun onTimeOut() {

    }
}